<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/12/7
  Time: 21:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <jsp:include page="/WEB-INF/jsp/head.jsp">
        <jsp:param value="银行卡管理" name="pageTitle"/>
    </jsp:include>
    <script src="/js/common.js"></script>
</head>

<style>
    a:link {color:green;}
    a:hover {color:#FF00FF;}
</style>
<body class="easyui-layout">


<div class="easyui-panel" data-options="fit:true" style="width:100%;height:100%;padding:10px;">
    <table id="bankCardTb" class="easyui-datagrid" style="width:100%;height:100%">

    </table>
    <div id="tb" style="padding:20px;width:100%;">
        <a id="lbtnAdd" title="新增银行卡" href="#"  class="easyui-linkbutton" style="width:80px;"><i class="fa fa-plus"></i>新增</a>
        <a id="lbtnAlter" title="修改银行卡" href="#"  class="easyui-linkbutton" style="width:80px;"><i class="fa fa-plus"></i>修改</a>
        <a id="lbtnDel" href="#" class="easyui-linkbutton"style="width:80px;"><i class="fa fa-trash-o"></i>删除</a>
        <a id="flush_btn" href="#" class="easyui-linkbutton"style="width:80px; "><i class="fa fa-refresh"></i>刷新</a>
    </div>
</div>


<script>



        //刷新
        $("#flush_btn").click(function(){
            location.reload();
        });


        //新增项目显示
        $('#lbtnAdd').click( function (e) {
            e.preventDefault();
            e.stopPropagation();
            window.location.href = "/bankCard/toInsetBankCard";
        });




        //修改项目信息
        $('#lbtnAlter').click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            var rows = $('#bankCardTb').datagrid('getSelections');

            if (rows.length == 0 || rows.length>1) {
                $.messager.show({
                    title: '修改银行卡信息',
                    msg: "必须选择一项进行修改",
                    timeout: 5000,
                    showType: 'slide'
                });
            }

            if (rows.length == 1){
                var row = $('#bankCardTb').datagrid('getSelected');
                var bid = row.bid;
                var url = "/bankCard/toInsetBankCard?bid=" + bid;
                self.location.href = url;
            }

        });



    //批量删除
    $("#lbtnDel").click(function(){
        var rows = $('#bankCardTb').datagrid('getSelections');
        if(rows.length == 0){
            $.messager.show({
                title:'删除项目',
                msg:"未选中记录",
                timeout:5000,
                showType:'slide'
            });
        }
        if(rows.length >= 1){
            $.messager.confirm("删除警告", "您确定要删除共"+rows.length+"记录吗？", function (data) {
                if (data) {
                    var ids = [];
                    for(var i=0; i<rows.length; i++){
                        ids.push(rows[i].bid);
                    }
                    $.ajax({
                        type:"POST",
                        url:"/bankCard/deleteAllBankCard",
                        data:{
                            "deleteIdString":ids.toString()
                        },
                        dataType:"json",
                        success: function(data){
                            $.messager.alert('提示信息', data['msg'], 'info', function () {
                                //跳转地址
                                location.href = "/bankCard/home";
                            });
                            $('.panel-tool-close').hide();//隐藏关闭按钮
                        }
                    })
                }
                else {}
            });
        }
    });



    $('#bankCardTb').datagrid({
        iconCls: 'icon-search',
        title: '银行卡基本信息',
        url: '/bankCard/getAll',
        queryParams: {},
        method: 'get',
        singleSelect: "false",
        checkOnSelect: 'false',
        rownumbers: true,
        pagination: true,
        toolbar: '#tb',
        pageSize: 20,
        pageList: [10, 20, 30],
        columns: [[
            {field: 'ck', checkbox: true}
            , {field: 'bid', align: 'center', width: '100', title: '银行卡id', hidden: "true"}
            , {field: 'codenumber', width: '300',align: 'left', title: '银行卡卡号'}
            , {field: 'alias', width: '100',align: 'left', title: '别名'}
            , {field: 'initialnum', align: 'right', width: '200', title: '卡上金额',formatter:formatNumber}
            , {field: 'thebank', align: 'center', width: '200', title: '所属银行'}
            , {field: 'thegame', align: 'center', width: '100', title: '所属游戏'}
            , {field: 'thegameid', align: 'left', width: '100', title: '所属游戏ID', hidden: "true"}
            , {field: 'isuse', align: 'left', width: '100', title: '是否使用',formatter:formatState}

        ]]
        ,onLoadSuccess: function (data) {
            if (data.total == 0) {
                $.messager.alert('提示信息', '没有相关记录！', 'warning');
            }
        }
    });

</script>
</body>
</html>
